<div>
<ol class="breadcrumb" >
    <li> <i class="fa fa-anchor"></i>
        &nbsp;消费管理
    </li>
    <li>消费列表</li>
</ol>
<div class="panel">
<div class="panel-heading" >
    <i class="fa fa-list"></i>
    &nbsp;&nbsp;消费记录表
</div>
<form class="search-form" action={:U("Bill/index")} method="get">
    <div class="panel-body search-panel-body retract"  >
        <div class="col-xs-8 search-col">
            <div class="input-group">
                <span class="input-group-addon">时间段</span>
                <input type="text" class="form-control required form_month" placeholder="开始日期" name="start_time" value="{$_GET['start_time']}"  data-date-format="yyyy-mm-dd" data-link-format="yyyy-mm-dd">
                <span class="input-group-addon">~~</span>
                <input type="text" class="form-control required form_month" placeholder="截止日期" value="{$_GET['end_time']}" name="end_time"  data-date-format="yyyy-mm-dd" data-link-format="yyyy-mm-dd">
                <span class="input-group-addon">卡号</span>
                <input type="text" name="user_pay_card" maxlength="20" class="form-control" value="{$_GET['user_pay_card']}" placeholder="会员卡号"></div>
        </div>
        <div class="col-xs-2 search-col">
            <button  type="submit" class="btn btn-warning">
                <i class="fa fa-search"></i>
                &nbsp;搜索
            </button>
        </div>
    </div>
</form>
<table  class="table table-bordered table-striped table-mcit" >
    <thead>
    <tr>
        <th >
            <empty name="is_order_name">
                <button class='btn btn-block btn-mcit' type='submit' >ID</button>
                <else/>
                <button class='btn btn-block btn-mcit btn-mcit-active'  type='submit'>
                    <if condition="$order_name eq 1">
                        <i class="fa fa-chevron-down"></i>
                        <else/>
                        <i class="fa fa-chevron-up"></i>
                    </if>
                    &nbsp;ID
                </button>
            </empty>
        </th>
        <th>
            <empty name="is_order_stu_num">
                <button class='btn btn-block btn-mcit' type='submit' >会员卡号</button>
                <else/>
                <button class='btn btn-block btn-mcit btn-mcit-active' type='submit'>
                        <if condition="$order_stu_num eq 1">
                        <i class="fa fa-chevron-down"></i>
                        <else/>
                        <i class="fa fa-chevron-up"></i>
                    </if>
                    &nbsp;会员卡号
                </button>
            </empty>
        </th>
        <th>
            <empty name="is_order_stu_num">
                <button class='btn btn-block btn-mcit' type='submit' >充电时长(小时)</button>
                <else/>
                <button class='btn btn-block btn-mcit btn-mcit-active' type='submit' >
                    <if condition="$order_stu_num eq 1">
                        <i class="fa fa-chevron-down"></i>
                        <else/>
                        <i class="fa fa-chevron-up"></i>
                    </if>
                    &nbsp;充电时长
                </button>
            </empty>
        </th>
        <th>
            <empty name="is_order_stu_num">
                <button class='btn btn-block btn-mcit' type='submit' >充电电量(度)</button>
                <else/>
                <button class='btn btn-block btn-mcit btn-mcit-active' type='submit' >
                    <if condition="$order_stu_num eq 1">
                        <i class="fa fa-chevron-down"></i>
                        <else/>
                        <i class="fa fa-chevron-up"></i>
                    </if>
                    &nbsp;充电电量(度)
                </button>
            </empty>
        </th>
        <th>
            <empty name="is_order_idcard">
                <button class='btn btn-block btn-mcit' type='submit' >消费金额</button>
                <else/>
                <button class='btn btn-block btn-mcit btn-mcit-active' type='submit'>
                    <if condition="$order_idcard eq 1">
                        <i class="fa fa-chevron-down"></i>
                        <else/>
                        <i class="fa fa-chevron-up"></i>
                    </if>
                    &nbsp;消费金额
                </button>
            </empty>
        </th>
        <th>
            <empty name="is_order_major">
                <button class='btn btn-block btn-mcit' type='submit' >充电地点</button>
                <else/>
                <button class='btn btn-block btn-mcit btn-mcit-active' type='submit' >
                    <if condition="$order_major eq 1">
                        <i class="fa fa-chevron-down"></i>
                        <else/>
                        <i class="fa fa-chevron-up"></i>
                    </if>
                    &nbsp;充电地点
                </button>
            </empty>
        </th>
        <th>
            <empty name="is_order_tel">
                <button class='btn btn-block btn-mcit' type='submit' >站点名称</button>
                <else/>
                <button class='btn btn-block btn-mcit btn-mcit-active' type='submit' >
                    <if condition="$order_tel eq 1">
                        <i class="fa fa-chevron-down"></i>
                        <else/>
                        <i class="fa fa-chevron-up"></i>
                    </if>
                    &nbsp;站点名称
                </button>
            </empty>
        </th>
        <th>
            <empty name="is_order_edit_self">
                <button class='btn btn-block btn-mcit' type='submit' >操作</button>
                <else/>
                <button class='btn btn-block btn-mcit btn-mcit-active' type='submit' >
                    <if condition="$order_edit_self eq 1">
                        <i class="fa fa-chevron-down"></i>
                        <else/>
                        <i class="fa fa-chevron-up"></i>
                    </if>
                    &nbsp;操作
                </button>
            </empty>
        </th>
    </tr>
    </thead>
    <tbody id="DataTableContent">
    <empty name="pay">
        <td colspan="99" style="text-align:center" class="danger"> <strong><i class="fa fa-meh-o"></i>
            &nbsp;&nbsp;当前条件下没有数据</strong>
        </td>
        <else />
        <volist name="pay" id="data">
            <tr>
                <td>{$data.id}</td>
                <td>{$data.user_pay_card}</td>
                <td>{$data.time_num}</td>
                <td>{$data.this_reading}</td>
                <td>&yen;&nbsp;&nbsp;{$data.this_amount}</td>
                <td>{$data.location_text}</td>
                <td><span title="{$data.plant_text}">{$data.plant_name}</span></td>
                <td>
                    <a class="btn btn-success btn-sm" href="__URL__/detail/id/{$data.id}">
                        <i class="fa fa-eye"></i>
                        &nbsp;详情
                    </a>
                    <if condition="$_SESSION['role'] eq 805 || $_SESSION['role'] eq 802">
                        <a class="btn btn-sm btn-danger deleteBtn" href="#confirmDelete" data-target="#confirmDelete" data-toggle="modal" data-id='{$data.id}'><i class="fa fa-trash-o"></i>
                            &nbsp;删除</a>
                        <else /></if>
                </td>
            </tr>
        </volist>
    </empty>

    <tr>
        <td colspan="99" style="text-align:center">
            <ul class="pagination">{$pageView}</ul>
        </td>
    </tr>
    </tbody>
</table>
</div>
</div>
<!-- 删除分类 -->
<div id="confirmDelete" class="modal  fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
     aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 id="myModalLabel">是否确认删除当前记录？</h4>
            </div>
            <div class="modal-body" style="color: #D2322D">
                注意！删除后将不可恢复，<b class="alert-danger">请谨慎操作</b>。
            </div>
            <div class="modal-footer">
                <a class="btn" data-dismiss="modal" aria-hidden="true" id="modelClose">关闭</a>
                <a class="btn btn-primary" id="confirmDeleteBtn">确定</a>
            </div>
        </div></div>
    <div class="hide" id="cache">1</div>
</div>
<import file="js.jquery#chained" />
<import type='css' file="css.datetimepicker" />
<import file="js.bootstrap-datetimepicker#min" />
<import file="js.bootstrap-datetimepicker#zh-CN" />
<import file="js.maskedinput" />
<script type="text/javascript">
    $(document).ready(function () {
        $("#location-s").chained("#location-f");
        $("#location-t").chained("#location-s");

        $(".form_month").datetimepicker({
            language: 'zh-CN',
            autoclose: true,
            startView:'month',
            minView: 'month',
            todayBtn: true,
            viewSelect: 'year',
            pickerPosition: "bottom-left"
        });

        $(".deleteBtn").click(function (){
            var id = $(this).attr("data-id");
            $("#cache").val(id);
        });
        $("#confirmDeleteBtn").click(function (){
            var id = $("#cache").val();
            //alert(id);
            $.ajax({
                type:"post",
                url:'__URL__/delBill',
                data:'id='+id,
                success:function(data){
                    if(data == 1){
                        alertify.success("删除成功！");
                    }else{
                        alertify.error("删除失败，请重新提交！");
                    }
                    location.reload();
                }
            });
        });

    });
</script>